package com.gravata.enigma.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.gravata.enigma.R;
import com.gravata.enigma.model.Bouquet;

public class BouquetListAdapter extends ArrayAdapter<Bouquet> {

	private LayoutInflater mInflater;

	public BouquetListAdapter(Context context,  List<Bouquet> bouquets) {
		super(context, 0);
		init(context);
	}

	private void init(Context context) {
		this.mInflater = LayoutInflater.from(context);
	}


	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final ViewHolder vh;
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.item_bouquet_servico, parent, false);
			vh = new ViewHolder(convertView);
			convertView.setTag(vh);
		} else {
			vh = (ViewHolder) convertView.getTag();
		}

		Bouquet item=getItem(position);
		vh.textView.setText(item.getName());

		return convertView;
	}


	static class ViewHolder {

		TextView textView;

		private ViewHolder(View rootView) {
			textView = (TextView) rootView.findViewById(R.id.textView1);
		}
	}



}
